<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>立即下单</title>
	<link href="${pageContext.request.contextPath }/client/css/main.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
</head>
<body>
	<%@include file="./include/head.jsp" %>
	<%@include file="./include/menu_search.jsp" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

	<div class="container" style="padding: 25px 0;">
		<form action="${pageContext.request.contextPath }/PurchaseServlet" method="post">
			<div class="panel panel-default">
				<div class="panel-heading">商品列表</div>
				<div class="panel-body">
					<c:forEach items="${products}" var="p">
						<div class="media">
							<div class="media-left media-middle">
								<img class="media-object" src="${p.getImgurl()}" alt="${p.getName()}" style="width:64px;height: 64px;">
							</div>
							<div class="media-body">
								<h4 class="media-heading">${p.getName()}</h4>
								<p>数量：${p.getSelect()}<br>价格：￥${p.getSelect() * p.getPrice()}</p>
							</div>
						</div>
					</c:forEach>
				</div>
			</div>
			
			<div class="panel panel-default">
				<div class="panel-heading">选择地址</div>
				<div class="panel-body">
					<c:if test="${addresses.size() == 0}">
						<div class="alert alert-danger" role="alert">请添加收货地址</div>
					</c:if>
					<c:forEach items="${addresses}" var="address" varStatus="status">
						<div class="radio">
							<label>
								<input type="radio" name="address" value="${address.getId()}" <c:if test="${status.index == 0}"> checked </c:if>>
								${address.getName()}-${address.getTelephone()}-${address.getAddress()}
							</label>
						</div>
					</c:forEach>
				</div>
			</div>
			
			<div class="panel panel-default">
				<div class="panel-heading">选择支付方式</div>
				<div class="panel-body">
					<div class="form-inline">
						<div class="radio">
							<label>
								<input type="radio" name="payment" value="wechat" checked>
								微信支付
							</label>
						</div>
						<div class="radio">
							<label>
								<input type="radio" name="payment" value="alipay">
								支付宝支付
							</label>
						</div>
						<div class="radio">
							<label>
								<input type="radio" name="payment" value="visa">
								银联支付
							</label>
						</div>
					</div>
				</div>
			</div>
			
			<div class="clearfix">
				<button type="submit" class="btn btn-primary btn-lg pull-right">立即结算</button>
				<h4 class="pull-right" style="margin-right: 15px;"	>总价：￥${amount}</h4>
			</div>
		</form>
	</div>
	
	<%@include file="./include/foot.jsp" %>
</body>
</html>